package bearworker.zxl.dao.mapper.extra;

import bearworker.zxl.entity.extra.DeliveryOrdDtlRecive;
import bearworker.zxl.entity.extra.DeliveryOrdSenderEntity;
import bearworker.zxl.entity.extra.DeliveryPreOrderReciver;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * Created by 逍遥的熊 on 2018/2/11.
 */
public interface DeliveryExtraMapper {

    @SelectProvider(type = DeliveryExtraSqlProvider.class,method = "getOrderPreRecive")
    @Results({
            @Result(column = "id",property = "id",jdbcType = JdbcType.INTEGER),
            @Result(column = "province",property = "province",jdbcType = JdbcType.VARCHAR),
            @Result(column = "city",property = "city",jdbcType = JdbcType.VARCHAR),
            @Result(column = "district",property = "district",jdbcType = JdbcType.VARCHAR),
            @Result(column = "recipients_address",property = "address",jdbcType = JdbcType.VARCHAR),
            @Result(column = "recipients_name",property = "name",jdbcType = JdbcType.INTEGER),
            @Result(column = "recipients_telephone",property = "telephone",jdbcType = JdbcType.VARCHAR),
            @Result(column = "package_kilo",property = "packageKilo",jdbcType = JdbcType.INTEGER),
            @Result(column = "original_price",property = "originalPrice",jdbcType = JdbcType.INTEGER),
            @Result(column = "sender_id",property = "senderId",jdbcType = JdbcType.INTEGER)
    })
    List<DeliveryPreOrderReciver> getSenderRePreOrd(@Param("senderId") Integer senderId);

    @SelectProvider(type = DeliveryExtraSqlProvider.class,method = "getOrdDtlRecive")
    @Results({
            @Result(column = "id",property = "id",jdbcType = JdbcType.INTEGER),
            @Result(column = "order_id",property = "orderId",jdbcType = JdbcType.INTEGER),
            @Result(column = "pre_ord_id",property = "preOrdId",jdbcType = JdbcType.INTEGER),
            @Result(column = "recipients_id",property = "recipientsId",jdbcType = JdbcType.INTEGER),
            @Result(column = "package_kilo",property = "packageKilo",jdbcType = JdbcType.DOUBLE),
            @Result(column = "original_price",property = "originalPrice",jdbcType = JdbcType.INTEGER),
            @Result(column = "courier_number",property = "courierNumber",jdbcType = JdbcType.VARCHAR),
            @Result(column = "showTime",property = "showTime",jdbcType = JdbcType.VARCHAR),
            @Result(column = "user_id",property = "userId",jdbcType = JdbcType.INTEGER),
            @Result(column = "recipients_name",property = "recipientsName",jdbcType = JdbcType.VARCHAR),
            @Result(column = "recipients_telephone",property = "recipientsTelephone",jdbcType = JdbcType.VARCHAR),
            @Result(column = "province",property = "province",jdbcType = JdbcType.VARCHAR),
            @Result(column = "city",property = "city",jdbcType = JdbcType.VARCHAR),
            @Result(column = "district",property = "district",jdbcType = JdbcType.VARCHAR),
            @Result(column = "recipients_address",property = "recipientsAddress",jdbcType = JdbcType.VARCHAR),
    })
    List<DeliveryOrdDtlRecive> getOrdDtlRecive(@Param("orderId") Integer orderId);

    @SelectProvider(type = DeliveryExtraSqlProvider.class,method = "getPackageByUserId")
    @Results({
            @Result(column = "id",property = "id",jdbcType = JdbcType.INTEGER),
            @Result(column = "order_id",property = "orderId",jdbcType = JdbcType.INTEGER),
            @Result(column = "pre_ord_id",property = "preOrdId",jdbcType = JdbcType.INTEGER),
            @Result(column = "recipients_id",property = "recipientsId",jdbcType = JdbcType.INTEGER),
            @Result(column = "package_kilo",property = "packageKilo",jdbcType = JdbcType.DOUBLE),
            @Result(column = "original_price",property = "originalPrice",jdbcType = JdbcType.INTEGER),
            @Result(column = "courier_number",property = "courierNumber",jdbcType = JdbcType.VARCHAR),
            @Result(column = "showTime",property = "showTime",jdbcType = JdbcType.VARCHAR),
            @Result(column = "user_id",property = "userId",jdbcType = JdbcType.INTEGER),
            @Result(column = "recipients_name",property = "recipientsName",jdbcType = JdbcType.VARCHAR),
            @Result(column = "recipients_telephone",property = "recipientsTelephone",jdbcType = JdbcType.VARCHAR),
            @Result(column = "province",property = "province",jdbcType = JdbcType.VARCHAR),
            @Result(column = "city",property = "city",jdbcType = JdbcType.VARCHAR),
            @Result(column = "district",property = "district",jdbcType = JdbcType.VARCHAR),
            @Result(column = "recipients_address",property = "recipientsAddress",jdbcType = JdbcType.VARCHAR),
    })
    List<DeliveryOrdDtlRecive> getPackageByUserId(@Param("userId") Integer userId);

    @SelectProvider(type = DeliveryExtraSqlProvider.class,method = "getOrdsByState")
    @Results({
            @Result(column = "id",property = "id",jdbcType = JdbcType.INTEGER),
            @Result(column = "order_no",property = "orderNo",jdbcType = JdbcType.VARCHAR),
            @Result(column = "original_price",property = "originalPrice",jdbcType = JdbcType.INTEGER),
            @Result(column = "ord_time",property = "ordTime",jdbcType = JdbcType.VARCHAR),
            @Result(column = "sender_name",property = "senderName",jdbcType = JdbcType.VARCHAR),
            @Result(column = "sender_telephone",property = "senderTelephone",jdbcType = JdbcType.VARCHAR),
            @Result(column = "province",property = "province",jdbcType = JdbcType.VARCHAR),
            @Result(column = "city",property = "city",jdbcType = JdbcType.VARCHAR),
            @Result(column = "district",property = "district",jdbcType = JdbcType.VARCHAR),
            @Result(column = "sender_address",property = "senderAddress",jdbcType = JdbcType.VARCHAR),
            @Result(column = "state",property = "state",jdbcType = JdbcType.INTEGER)
    })
    List<DeliveryOrdSenderEntity> getOrdByState(@Param("state") Integer state);
}
